<?php

ob_start();

define('NUO_API', 1);

require_once 'application/setting/autoload.php';

Nuo::init();

$q = $_GET['q'];

$ret = array(
	'q' => $q,
	'rows' => array()
);

$i = 1;

$table = Nuo::getTable('user');

$db = Database::instance();

$esc = trim($db -> quote(substr($q, 1)), "'");

$select = $table -> select() -> where("full_name like '%{$esc}%'") -> limit(10);

$rows = $table -> fetchAll($select);

foreach ($rows as $row)
{
	$ret['rows'][] = array(
		'text' => $row -> getTitle(),
		'type' => $row -> getType(),
		'id' => $row -> getId(),
		'photo' => $row -> getPhotoUrl('s50'),
	);
}

echo json_encode($ret);
